home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <html><head><title>Function Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03090406"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
-
- p.P1{
- }
- p.P2{
- }
- span.T1{
- font-weight:bold;}
- </style></head><body>
-
-
- <help:to-be-embedded Eid="function" xmlns:help="http://openoffice.org/2000/help">
- <p class="Head1"><help:link Id="66518">Function Statement [Runtime]</help:link></p>
- <p class="Paragraph">Defines a subprocedure which can be used as an expression to determine a return type.</p>
- </help:to-be-embedded>
- <p class="P2">Syntax</p>
- <p class="Paragraph">see Parameter <help:key-word value="Function" tag="kw66518_1" xmlns:help="http://openoffice.org/2000/help"/></p>
- <p class="Paragraph"><span class="T1">Parameter</span>:</p>
- <p class="Paragraph">Syntax</p>
- <p class="Paragraph"><help:key-word value="Function" tag="kw66518_2" xmlns:help="http://openoffice.org/2000/help"/>Function Name[(VarName1 [As Type][, VarName2 [As Type][,...]]]) [As Type]</p>
- <p class="Paragraph">statement block</p>
- <p class="Paragraph">[Exit Function]</p>
- <p class="Paragraph">statement block</p>
- <p class="Paragraph">End Function</p>
- <p class="Paragraph">Parameter</p>
- <p class="Paragraph">Name: Name of the subprocedure to contain the value returned by the function.</p>
- <p class="Paragraph">VarName: Parameter to be passed to the subprocedure.</p>
- <p class="Paragraph">Type :Type-declaration keyword.</p>
- <p class="P2">Example:</p>
- <p class="PropText">Sub ExampleExit</p>
- <p class="PropText">Dim sReturn As String</p>
- <p class="PropText">Dim sListArray(10) as String</p>
- <p class="PropText">Dim siStep as Single</p>
- <p class="PropText">For siStep = 0 to 10 <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>REM Fill array with test data</p>
- <p class="PropText">sListArray(siStep) = chr$(siStep + 65)</p>
- <p class="PropText">msgbox sListArray(siStep)</p>
- <p class="PropText">next siStep</p>
- <p class="PropText">sReturn = LinSearch(sListArray(), "B")</p>
- <p class="PropText">Print sReturn</p>
- <p class="PropText">end sub</p>
- <p class="PropText"/>
- <p class="PropText"/>
- <p class="PropText">Function LinSearch( sList(), sItem As String ) as integer</p>
- <p class="PropText">dim iCount as Integer</p>
- <p class="PropText">REM Linsearch searches a TextArray:sList() for a TextEntry:</p>
- <p class="PropText">REM Return value is the index of the entry or 0 (Null)</p>
- <p class="PropText">for iCount=1 to Ubound( sList() )</p>
- <p class="PropText">if sList( iCount ) = sItem then</p>
- <p class="PropText">exit for REM sItem found</p>
- <p class="PropText">end if</p>
- <p class="PropText">next iCount</p>
- <p class="PropText">if iCount = Ubound( sList() ) then iCount = 0</p>
- <p class="PropText">LinSearch = iCount</p>
- <p class="PropText">end function</p>
- <p class="PropText"/>
- <p class="PropText"/>
- </body></html>